<include file="public@header" />
</head>
<body>
    <div class="wrap js-check-wrap">
        <ul class="nav nav-tabs">
            <li class="active"><a href="{:url('order/index')}">订单列表</a></li>
        </ul>
        <!-- <form class="well form-inline margin-top-20" method="get" action="{:url('order/index')}">
            合同编号:
            <input type="text" class="form-control" name="contract_no" style="width: 150px;" value="{:input('request.contract_no/s','')}">
            支出日期:
            <input type="text" class="form-control js-bootstrap-date" name="date" style="width: 150px;" value="{:input('request.date/s','')}" autocomplete="off">
            <input type="submit" class="btn btn-primary" value="搜索" />
            <a class="btn btn-danger" href="{:url('order/index')}">清空</a>
        </form> -->
        <br>
        <table class="table table-hover table-bordered">
            <thead>
                <tr>
                    <th width="50">ID</th>
                    <th>代理商</th>
                    <th>产品信息</th>
                    <th>相关项目</th>
                    <th>收货信息</th>
                    <th>订单报价</th>
                    <th>状态</th>
                    <th width="140">{:lang('ACTIONS')}</th>
                </tr>
            </thead>
            <tbody>
                <foreach name="list" item="vo">
                    <tr>
                        <td>{$vo.id}</td>
                        <td>{$vo.agent.name}</td>
                        <td>{$vo.title}</td>
                        <td>{$vo.project.title}|{$vo.project.project_no}</td>
                        <td>{$vo.contact_name}<br>{$vo.contact_number}<br>{$vo.address}</td>
                        <td>{$vo.amount|floatval}</td>
                        <td>{$vo.status_text}</td>
                        <td>
                            <a class="btn btn-xs btn-primary" href="javascript:parent.openIframeLayer('{:url('order/content',array('id'=>$vo['id']))}','订单需求',{area:['50%','70%']});">订单需求</a>
                            <a class="btn btn-xs btn-primary" href="javascript:parent.openIframeLayer('{:url('order/project_detail',array('project_id'=>$vo['project_id']))}','项目详情',{area:['50%','70%']});">项目详情</a>
                            <if $vo.status == 1 || $vo.status == 2>
                                <a class="btn btn-xs btn-primary receive" data-id="{$vo.id}">接单报价</a>
                            </if>
                            <if $vo.status == 1>
                                <a class="btn btn-xs btn-primary refuse" data-id="{$vo.id}">拒绝接单</a>
                            </if>
                            <a class="btn btn-xs btn-primary" href="javascript:parent.openIframeLayer('{:url('order/payment',array('id'=>$vo['id']))}','打款记录',{area:['50%','70%']});">打款记录</a>
                            <a class="btn btn-xs btn-primary" href="javascript:parent.openIframeLayer('{:url('order/send',array('id'=>$vo['id']))}','发货记录',{area:['50%','70%']});">发货记录</a>
                            <if $vo.status == 3>
                                <a class="btn btn-xs btn-primary send" data-id="{$vo.id}">已发货</a>
                            </if>
                        </td>
                    </tr>
                </foreach>
            </tbody>
        </table>
        <div class="pagination">{$page}</div>
    </div>
    <script src="__STATIC__/js/admin.js"></script>
    <script src="__STATIC__/layui/layui.js"></script>
    <script type="text/javascript">
        layui.use(['layer'], function(){
            var layer = layui.layer;

            $('.receive').click(function(){
                var id = $(this).data('id');
                layer.prompt({
                    title: '请输入订单价格',
                },
                function(value, index, elem){
                    $.ajax({
                        type: 'get',
                        url: '{:url("order/receive")}',
                        data: {id:id,amount:value},
                        success:function(res) {
                            layer.msg(res.msg)
                            setTimeout(function(){
                                layer.close(index);
                                location.reload();
                            },1000);
                        }
                    });
                });
            });

            $('.refuse').click(function(){
                var id = $(this).data('id');
                layer.confirm('请确认！', {icon: 7, title:'提示'}, function(index){
                    $.ajax({
                        type: 'get',
                        url: '{:url("order/refuse")}',
                        data: {id:id},
                        success:function(res) {
                            layer.msg(res.msg)
                            setTimeout(function(){
                                layer.close(index);
                                location.reload();
                            },1000);
                        }
                    });
                });
            });

            $('.send').click(function(){
                var id = $(this).data('id');
                layer.confirm('请确认！', {icon: 7, title:'提示'}, function(index){
                    $.ajax({
                        type: 'get',
                        url: '{:url("order/send_confirm")}',
                        data: {id:id},
                        success:function(res) {
                            layer.msg(res.msg)
                            setTimeout(function(){
                                layer.close(index);
                                location.reload();
                            },1000);
                        }
                    });
                });
            });

        });
    </script>
</body>
</html>